package com.chj.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.kafka.core.KafkaTemplate;

public class KafkaUtils {

	protected final static Logger logger = LoggerFactory.getLogger(KafkaUtils.class);

	public static void sendMessage(String topic, String key, Object message) {
		@SuppressWarnings("unchecked")
		KafkaTemplate<String, Object> kafkaTemplate = ApplicationContextUtil.getBean(KafkaTemplate.class);
		logger.info("kafka的消息 topic={}, key={}, message={}", topic, key, message);
		kafkaTemplate.send(topic, key, message);
		logger.info("kafka消息发送成功");
	}
}
